import type {
  PlatformElementConfig,
  SearchFrameworkConfig,
} from '../../interfaces'
import { preprocessElementConfigs } from '../personalization'
import { COMMON_PAGE_ELEMENTS } from './common'

/**
 * 页面元素配置
 */
export const BIAN_PAGE_ELEMENTS: Record<string, PlatformElementConfig> = {
  SHORTCUTS: {
    ...COMMON_PAGE_ELEMENTS.SHORTCUTS,
  },
  PAGE_THEME: {
    ...COMMON_PAGE_ELEMENTS.PAGE_THEME,
  },
  PAGE_LOADING: {
    ...COMMON_PAGE_ELEMENTS.PAGE_LOADING,
  },
  PAGE_ELEMENTS: {
    ...COMMON_PAGE_ELEMENTS.PAGE_ELEMENTS,
  },
}

// 预处理配置
const PROCESSED_BIAN_ELEMENTS = preprocessElementConfigs(BIAN_PAGE_ELEMENTS)
export type BianElements = typeof BIAN_PAGE_ELEMENTS

export const BIAN_FRAMEWORK_CONFIG: Partial<SearchFrameworkConfig> = {
  GLOBAL: {
    shortcuts: [
      PROCESSED_BIAN_ELEMENTS.SHORTCUTS,
    ],
    pageTheme: [
      PROCESSED_BIAN_ELEMENTS.PAGE_THEME,
    ],
    loadingTheme: [
      PROCESSED_BIAN_ELEMENTS.PAGE_LOADING,
    ],
    loadingPhrases: [
      PROCESSED_BIAN_ELEMENTS.PAGE_LOADING,
    ],
  },
}
